﻿using LotusIslandOrderProcessing.PLCMake;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;

namespace LotusIslandOrderProcessing.model
{
    public class OrderRequst
    {
        private static OrderRequst instance;
        private OrderRequst() { }
        public static OrderRequst Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new OrderRequst();
                }
                return instance;
            }
        }
        /// <summary>
        /// 奶茶1
        /// </summary>
        /// <param name="ClassCode">品类</param>
        /// <param name="MilkCode">杯型</param>
        /// <param name="IceCode">冰量</param>
        /// <param name="SugarCode">糖量</param>
        /// <param name="DYCode">打印</param>
        /// <param name="OrderNumber">订单号</param>
        public void OrderMilkTea1(int ClassCode, int IceCode, int SugarCode, int MilkCode, int DYCode, string OrderNumber)
        {
            try
            {
                List<object> Writelist = new List<object>();
                for (int i = 0; i < 2; i++)
                {
                    PlcListWrite plc = new PlcListWrite();
                    plc.var = i == 0 ? CoffeeModel.Instance.Action3 : i == 1 ? CoffeeModel.Instance.Order30 : i == 2 ? CoffeeModel.Instance.Order31 : i == 3 ? CoffeeModel.Instance.Order32 : i == 4 ? CoffeeModel.Instance.Order33 : CoffeeModel.Instance.Order34;
                    plc.value = i == 0 ? 1 : i == 1 ? ClassCode : i == 2 ? IceCode : i == 3 ? SugarCode : i == 4 ? MilkCode : DYCode;
                    PlcModelWrite model = new PlcModelWrite();
                    model.paramss = plc;
                    model.method = "PlcProgram.Write";
                    model.id = 1;
                    Writelist.Add(model);
                }
                PlcOrderWrite plc2 = new PlcOrderWrite();
                plc2.var = CoffeeModel.Instance.Order_Number3;
                plc2.value = OrderNumber;
                PlcModelsWrite model2 = new PlcModelsWrite();
                model2.paramss = plc2;
                model2.method = "PlcProgram.Write";
                model2.id = 1;
                Writelist.Add(model2);
                var Writelists = JsonConvert.SerializeObject(Writelist);
                var readlist = HttpClient.Instance.HttpPostRaw("", Writelists, HttpClient.url_start);
            }
            catch (Exception)
            {
            }
        }
        /// <summary>
        /// 奶茶2
        /// </summary>
        /// <param name="ClassCode">品类</param>
        /// <param name="MilkCode">杯型</param>
        /// <param name="IceCode">冰量</param>
        /// <param name="SugarCode">糖量</param>
        /// <param name="DYCode">打印</param>
        /// <param name="OrderNumber">订单号</param>
        public void OrderMilkTea2(int ClassCode, int IceCode, int SugarCode, int MilkCode, int DYCode, string OrderNumber)
        {
            try
            {
                List<object> Writelist = new List<object>();
                for (int i = 0; i < 2; i++)
                {
                    PlcListWrite plc = new PlcListWrite();
                    plc.var = i == 0 ? CoffeeModel.Instance.Action4 : i == 1 ? CoffeeModel.Instance.Order40 : i == 2 ? CoffeeModel.Instance.Order41 : i == 3 ? CoffeeModel.Instance.Order42 : i == 4 ? CoffeeModel.Instance.Order43 : CoffeeModel.Instance.Order44;
                    plc.value = i == 0 ? 1 : i == 1 ? ClassCode : i == 2 ? IceCode : i == 3 ? SugarCode : i == 4 ? MilkCode : DYCode;
                    PlcModelWrite model = new PlcModelWrite();
                    model.paramss = plc;
                    model.method = "PlcProgram.Write";
                    model.id = 1;
                    Writelist.Add(model);
                }
                PlcOrderWrite plc2 = new PlcOrderWrite();
                plc2.var = CoffeeModel.Instance.Order_Number4;
                plc2.value = OrderNumber;
                PlcModelsWrite model2 = new PlcModelsWrite();
                model2.paramss = plc2;
                model2.method = "PlcProgram.Write";
                model2.id = 1;
                Writelist.Add(model2);
                var Writelists = JsonConvert.SerializeObject(Writelist);
                var readlist = HttpClient.Instance.HttpPostRaw("", Writelists, HttpClient.url_start);
            }
            catch (Exception)
            {
            }
        }
        /// <summary>
        /// 打印流程
        /// </summary>
        /// <param name="ClassCode">打印品类</param>
        /// <param name="overPrint">打印过程</param>
        public void OrderPrint(int ClassCode, int overPrint)
        {
            try
            {
                List<object> Writelist = new List<object>();
                PlcListWrite plc = new PlcListWrite();
                plc.var = ClassCode == 3 ? CoffeeModel.Instance.Print3 : CoffeeModel.Instance.Print4;
                plc.value = overPrint;
                PlcModelWrite model = new PlcModelWrite();
                model.paramss = plc;
                model.method = "PlcProgram.Write";
                model.id = 1;
                Writelist.Add(model);
                var Writelists = JsonConvert.SerializeObject(Writelist);
                var readlist = HttpClient.Instance.HttpPostRaw("", Writelists, HttpClient.url_start);
            }
            catch (Exception)
            {
            }
        }
    }
}
